package com.dogdog.fragment;


import com.dogdog.UI.RoundedImageView;
import com.dogdog.activity.Hand_Notifications;
import com.dogdog.activity.Hand_userInfo;
import com.dogdog.activity.R;
import com.dogdog.bean.Me;
import com.dogdog.manager.MyApplication;

import android.app.Fragment;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

public class Hand_person extends Fragment implements OnClickListener {
	private View tab1;
	private TextView title;
	private RelativeLayout  titlebar;
	private RelativeLayout Notifications;
	Me mydata;
	private TextView person_name;
	private ImageView person_sex;
	private RoundedImageView person_face;

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		 tab1 = inflater.inflate(R.layout.fragment_main_person,container,false);
		 initView();
		return tab1;
	}

	private void initView() { 
		titlebar = (RelativeLayout) tab1. findViewById(R.id.rl_titlebar);
		title = (TextView)tab1 .findViewById(R.id.tv_title);
		title.setText("个人");
		Notifications = (RelativeLayout)tab1.findViewById(R.id.Notifications);
		Notifications.setOnClickListener(this);
	((RelativeLayout)tab1.findViewById(R.id.person_layout)).setOnClickListener(this);
		mydata = MyApplication.getMeData();
		person_name=(TextView)tab1.findViewById(R.id.person_name);
		person_name.setText(mydata.getName());
		person_face=(RoundedImageView)tab1.findViewById(R.id.face);
		person_face.setImageBitmap(mydata.getFaceBitmap());
		int[] sexs=new int[]{R.drawable.sex0,R.drawable.sex1,R.drawable.sex2};
	    person_sex=(ImageView)tab1.findViewById(R.id.sex);
	    person_sex.setImageDrawable(getResources().getDrawable(sexs[mydata.getSex()]));
	}

	@Override
	public void onClick(View v) {
		Intent intent;
		switch (v.getId()) {
		case  R.id.Notifications:
			intent = new Intent(getActivity(),Hand_Notifications.class);
			startActivity(intent);
			break;

		case R.id.person_layout:
			intent =new Intent(getActivity(),Hand_userInfo.class);
			startActivity(intent);
			break;
		
		default:
			break;
		}
	}
}
